package com.example.wn.eureka.listener;

import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceCanceledEvent;
import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRegisteredEvent;
import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRenewedEvent;
import org.springframework.cloud.netflix.eureka.server.event.EurekaServerStartedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

@Component
public class EventListenerDemo {

    @EventListener
    public void eventCancel(EurekaInstanceCanceledEvent event){
        System.out.println(event.getAppName()+"服务下线了");
    }

    @EventListener
    public void eventUp(EurekaServerStartedEvent event){
        System.out.println("服务启动了");
    }

    @EventListener
    public void eventRigister(EurekaInstanceRegisteredEvent event){
        System.out.println(event.getInstanceInfo().getAppName()+"注册了");
    }

    @EventListener
    public void eventReNew(EurekaInstanceRenewedEvent event){
        System.out.println(event.getAppName()+"续约了");
    }
}
